package thread.producer;

public class Producer extends Thread{

    //为了保证生产者和消费者使用同一个house将house作为参数传入到producer和consume
    private WareHouse house;
    public Producer(WareHouse house){
        this.house = house;
    }
    @Override
    //重写的方法参数和被重写的方法要保持一致
    public void run() {
        while (true){
            house.add();
            System.out.println("生产者生产了一个产品");
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
